﻿/*  
   File Browser for SalesForce
   Copyright (c) 2009  Daniel Jordan
  
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SFFileBrowser
{
    public partial class frmProperties : Form
    {
        internal SForceAttachmentInfo AttachmentInfo { get; set; }
        internal SForceUsers Users { get; set; }


        public frmProperties()
        {
            InitializeComponent();
        }

        private void frmProperties_Load(object sender, EventArgs e)
        {

        }

        public void UpdateDisplay()
        {
            this.lblSize.Text = AttachmentInfo.Size.ToString("#,##0 bytes");
            this.labelName.Text = AttachmentInfo.Name;
            this.labelType.Text = AttachmentInfo.Type;
            if (AttachmentInfo.LastModifiedDate != null)
            {
                labelModifiedDate.Text = AttachmentInfo.LastModifiedDate.ToShortDateString() + "  "
                    + AttachmentInfo.LastModifiedDate.ToShortTimeString();
            }
            else
            {
                labelModifiedDate.Text = "";
            }

            if (AttachmentInfo.CreatedDate != null)
            {
                this.labelCreatedDate.Text = AttachmentInfo.CreatedDate.ToShortDateString() + "  "
                    + AttachmentInfo.CreatedDate.ToShortTimeString();
            }
            else
            {
                this.labelCreatedDate.Text = "";
            }

            this.labelCreatedUser.Text = "";
            this.labelModifiedUser.Text = "";

            try
            {
                if (Users[AttachmentInfo.ModifiedUserID] != null)
                    this.labelModifiedUser.Text = Users[AttachmentInfo.ModifiedUserID].Name;

                if (Users[AttachmentInfo.CreatedUserID] != null)
                    this.labelCreatedUser.Text = Users[AttachmentInfo.CreatedUserID].Name;
            }
            catch{}
        }

        private void lblSize_Click(object sender, EventArgs e)
        {

        }

        private void buttonClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void label4_Click(object sender, EventArgs e)
        {

        }
       
    }
}
